basic file sorting by modified date

James Peret 8 years ago
parent
commit
e35e808b36

+ 21 - 2
app/scripts/services/file-service.js

@@ -284,11 +284,30 @@ angular.module('codexApp')
284 284
     return absoluteToRelativeURL(current_url, absolute_url);
285 285
   }
286 286
 
287
+  // Sort files
288
+  var date_sort_asc = function (date1, date2) {
289
+    // This is a comparison function that will result in dates being sorted in
290
+    // ASCENDING order. As you can see, JavaScript's native comparison operators
291
+    // can be used to compare dates. This was news to me.
292
+    if (date1.modified_at > date2.modified_at) return 1;
293
+    if (date1.modified_at < date2.modified_at) return -1;
294
+    return 0;
295
+  };
296
+
297
+  var date_sort_desc = function (date1, date2) {
298
+    // This is a comparison function that will result in dates being sorted in
299
+    // DESCENDING order.
300
+    if (date1.modified_at > date2.modified_at) return -1;
301
+    if (date1.modified_at < date2.modified_at) return 1;
302
+    return 0;
303
+  };
304
+
305
+
287 306
 
288 307
   // RESPONSE
289 308
   this.getNotes = function() {
290
-    notes = [];
291
-    return getAllFilesFromFolder();
309
+    notes = getAllFilesFromFolder();
310
+    return notes.sort(date_sort_asc);
292 311
   }
293 312
 
294 313
   this.getNote = function(path) {

+ 4 - 0
codex/Test-Stack/Notebook 2/Test-0001/index.md

@@ -6,3 +6,7 @@ Testing the codex app note structure.
6 6
 
7 7
 * [External Link](http://blog.j1x.co)
8 8
 * [Another note](../Test-0002/index.md)
9
+
10
+-----------
11
+
12
+[back](../../../index.md)

+ 11 - 3
codex/dev/codex-app/todos.md

@@ -2,7 +2,7 @@
2 2
 
3 3
 * [X] Download and install [photon](http://photonkit.com/components/)
4 4
 * [X] Install AngularJS
5
-* [X] Install JS Markdown converter (Redcarpet?)
5
+* [X] Install JS Markdown converter (Marked)
6 6
 * [X] Read files from disk
7 7
 * [X] Ace Editor
8 8
 * [X] Edit and save files
@@ -11,13 +11,21 @@
11 11
 * [X] Icon View
12 12
 * [X] Navigation History
13 13
 * [X] Syntax Highlight
14
+* [X] File Sorting Asc
15
+* [ ] Image View
16
+* [ ] All Files / All Notes View
17
+* [ ] Folders/Notebook view & navigation
18
+* [ ] Nav btns go to file views
14 19
 * [ ] Note versioning
15 20
 * [ ] Tags
16
-* [ ] External Links
21
+* [ ] External Links (browser view)
22
+* [ ] Save User settings
17 23
 * [ ] Preferences Panel
18 24
 * [ ] Welcome Panel
19 25
 * [ ] New file Dialog
20 26
 * [ ] Right Click Menus
21 27
 * [ ] Copy Note link
22 28
 * [ ] S3 Backup
23
-* [ ] Web Clipper
29
+* [ ] Web Clipper
30
+* [ ] Multiple source folders
31
+* [ ] Footer bar infos

+ 7 - 1
codex/inbox/test_note.md

@@ -50,4 +50,10 @@ This is a ```inline``` code block.
50 50
 
51 51
 ```
52 52
 This is a code block
53
-```
53
+```
54
+
55
+## Tables
56
+
57
+| header 1  | header 2  | header 3  |
58
+|-----------|-----------|-----------|
59
+| content 1 | content 2 | content 3 |